<?php

namespace App\Http\Controllers;

use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Routing\Controller as BaseController;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;

class Controller extends BaseController
{
    use AuthorizesRequests, DispatchesJobs, ValidatesRequests;

    public function user(){
        return session('userinfo');
    }

    protected function buildToolBarButton($menu_id){
        /*$str = "hello,{0},{1},{2}, {3}";
        $str = "<a id=\"a_{0}\" class=\"easyui-linkbutton\" style=\"float:left\"  plain=\"true\" href=\"javascript:;\" icon=\"{1}\"  title=\"{2}\">{3}</a>";

        str_format($str, "x0",'x1','x2', 'x3');*/
        $user = $this->user();
        $permissionButton = callApiServer('System.UserService.getMenuOperation', ['curr_menu_id'=>$menu_id]);

        $linkbtn_template = "<a id=\"a_{0}\" class=\"easyui-linkbutton\"  plain=\"true\" href=\"javascript:void(0);\" icon=\"{1}\"  title=\"{2}\" onclick=\"{4}\">{3}</a>";
        $buttons = '';
        foreach ($permissionButton as $button){
            $buttons .= str_format($linkbtn_template, $button['code'],$button['icon_style'],$button['name'],$button['name'], $button['func']);
        }

        return $buttons;
    }
}
